/**
 * 用户相关 WebSocket 事件处理器
 */
const handleUserRegistered = (io, socket) => {
  socket.on('server:user-registered', async ({ username, realName }) => {
    console.log(`[WebSocket] 发送用户注册成功通知，用户名=${username}`);
    io.emit('client:user-registered', { username, realName });
  });
};

const handleUserLoginSuccess = (io, socket) => {
  socket.on('server:user-login-success', async (user) => {
    console.log(`[WebSocket] 发送用户登录成功通知，用户名=${user.username}`);
    io.to(socket.id).emit('client:user-login-success', user);
  });
};

const handleUserVerified = (io, socket) => {
  socket.on('server:user-verified', async (user) => {
    console.log(`[WebSocket] 发送用户审核通过通知，用户名=${user.username}`);
    io.emit('client:user-verified', user);
  });
};

module.exports = {
  handleUserRegistered,
  handleUserLoginSuccess,
  handleUserVerified,
};